home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / GNU / emacs.inst / emacs19.idb / usr / gnu / info / elisp-29.z / elisp-29
Encoding:
GNU Info File  |  1994-08-02  |  50.5 KB  |  1,236 lines

  1. This is Info file elisp, produced by Makeinfo-1.55 from the input file
  2. elisp.texi.
  3.  
  4.    This version is newer than the second printed edition of the GNU
  5. Emacs Lisp Reference Manual.  It corresponds to Emacs Version 19.19.
  6.  
  7.    Published by the Free Software Foundation 675 Massachusetts Avenue
  8. Cambridge, MA 02139 USA
  9.  
  10.    Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
  11.  
  12.    Permission is granted to make and distribute verbatim copies of this
  13. manual provided the copyright notice and this permission notice are
  14. preserved on all copies.
  15.  
  16.    Permission is granted to copy and distribute modified versions of
  17. this manual under the conditions for verbatim copying, provided that
  18. the entire resulting derived work is distributed under the terms of a
  19. permission notice identical to this one.
  20.  
  21.    Permission is granted to copy and distribute translations of this
  22. manual into another language, under the above conditions for modified
  23. versions, except that this permission notice may be stated in a
  24. translation approved by the Foundation.
  25.  
  26.    Permission is granted to copy and distribute modified versions of
  27. this manual under the conditions for verbatim copying, provided also
  28. that the section entitled "GNU Emacs General Public License" is included
  29. exactly as in the original, and provided that the entire resulting
  30. derived work is distributed under the terms of a permission notice
  31. identical to this one.
  32.  
  33.    Permission is granted to copy and distribute translations of this
  34. manual into another language, under the above conditions for modified
  35. versions, except that the section entitled "GNU Emacs General Public
  36. License" may be included in a translation approved by the Free Software
  37. Foundation instead of in the original English.
  38.  
  39. 
  40. File: elisp,  Node: Holiday Customizing,  Next: Date Display Format,  Prev: Calendar Customizing,  Up: Calendar
  41.  
  42. Customizing the Holidays
  43. ========================
  44.  
  45.    Emacs knows about holidays defined by entries on one of several
  46. lists.  You can customize theses lists of holidays to your own needs,
  47. adding holidays or deleting lists of holidays.  The lists of holidays
  48. that Emacs uses are for general holidays (`general-holidays'), local
  49. holidays (`local-holidays'), Christian holidays (`christian-holidays'),
  50. Hebrew (Jewish) holidays (`hebrew-holidays'), Islamic (Moslem) holidays
  51. (`islamic-holidays'), and other holidays (`other-holidays').
  52.  
  53.    The general holidays are, by default, holidays common throughout the
  54. United States.  To eliminate these holidays, set `general-holidays' to
  55. `nil'.
  56.  
  57.    There are no default local holidays (but sites may supply some).  You
  58. can set the variable `local-holidays' to any list of holidays, as
  59. described below.
  60.  
  61.    By default, Emacs does not consider all the holidays of these
  62. religions, only those commonly found in secular calendars.  For a more
  63. extensive collection of religious holidays, you can set any (or all) of
  64. the variables `all-christian-calendar-holidays',
  65. `all-hebrew-calendar-holidays', or `all-islamic-calendar-holidays' to
  66. `t'.  If you want to eliminate the religious holidays, set any or all
  67. of the corresponding variables `christian-holidays', `hebrew-holidays',
  68. and `islamic-holidays' to `nil'.
  69.  
  70.    You can set the variable `other-holidays' to any list of holidays.
  71. This list, normally empty, is intended for your use.
  72.  
  73.    Each of the lists (`general-holidays', `local-holidays',
  74. `christian-holidays', `hebrew-holidays', `islamic-holidays', and
  75. `other-holidays') is a list of "holiday forms", each holiday form
  76. describing a holiday (or sometimes a list of holidays).  Holiday forms
  77. may have the following formats:
  78.  
  79. `(fixed MONTH DAY STRING)'
  80.      A fixed date on the Gregorian calendar.  MONTH and DAY are
  81.      numbers, STRING is the name of the holiday.
  82.  
  83. `(float MONTH DAYNAME K STRING)'
  84.      The Kth DAYNAME in MONTH on the Gregorian calendar (DAYNAME=0 for
  85.      Sunday, and so on); negative K means count back from the end of
  86.      the month.  STRING is the name of the holiday.
  87.  
  88. `(hebrew MONTH DAY STRING)'
  89.      A fixed date on the Hebrew calendar.  MONTH and DAY are numbers,
  90.      STRING is the name of the holiday.
  91.  
  92. `(islamic MONTH DAY STRING)'
  93.      A fixed date on the Islamic calendar.  MONTH and DAY are numbers,
  94.      STRING is the name of the holiday.
  95.  
  96. `(julian MONTH DAY STRING)'
  97.      A fixed date on the Julian calendar.  MONTH and DAY are numbers,
  98.      STRING is the name of the holiday.
  99.  
  100. `(sexp SEXP STRING)'
  101.      SEXP is a Lisp expression that should use the variable `year' to
  102.      compute the date of a holiday, or `nil' if the holiday doesn't
  103.      happen this year.  The value represents the date as a list of the
  104.      form `(MONTH DAY YEAR)'.  STRING is the name of the holiday.
  105.  
  106. `(if BOOLEAN HOLIDAY-FORM &optional HOLIDAY-FORM)'
  107.      A choice between two holidays based on the value of BOOLEAN.
  108.  
  109. `(FUNCTION &optional ARGS)'
  110.      Dates requiring special computation; ARGS, if any, are passed in a
  111.      list to the function `calendar-holiday-function-FUNCTION'.
  112.  
  113.    For example, suppose you want to add Bastille Day, celebrated in
  114. France on July 14.  You can do this by adding the following line to
  115. your `.emacs' file:
  116.  
  117.      (setq other-holidays '((fixed 7 14 "Bastille Day")))
  118.  
  119. The holiday form `(fixed 7 14 "Bastille Day")' specifies the fourteenth
  120. day of the seventh month (July).
  121.  
  122.    Many holidays occur on a specific day of the week, at a specific time
  123. of month.  Here is a holiday form describing Hurricane Supplication Day,
  124. celebrated in the Virgin Islands on the fourth Monday in August:
  125.  
  126.      (float 8 1 4 "Hurricane Supplication Day")
  127.  
  128. Here the 8 specifies August, the 1 specifies Monday (Sunday is 0,
  129. Tuesday is 2, and so on), and the 4 specifies the fourth occurrence in
  130. the month (1 specifies the first occurrence, 2 the second occurrence,
  131. -1 the last occurrence, -2 the second-to-last occurrence, and so on).
  132.  
  133.    You can specify holidays that occur on fixed days of the Hebrew,
  134. Islamic, and Julian calendars too.  For example,
  135.  
  136.      (setq other-holidays
  137.            '((hebrew 10 2 "Last day of Hanukkah")
  138.              (islamic 3 12 "Mohammed's Birthday")
  139.              (julian 4 2 "Jefferson's Birthday")))
  140.  
  141. adds the last day of Hanukkah (since the Hebrew months are numbered with
  142. 1 starting from Nisan), the Islamic feast celebrating Mohammed's
  143. birthday (since the Islamic months are numbered from 1 starting with
  144. Muharram), and Thomas Jefferson's birthday, which is 2 April 1743 on the
  145. Julian calendar.
  146.  
  147.    To include a holiday conditionally, use either the `if' or the
  148. `sexp' form.  For example, American presidential elections occur on the
  149. first Tuesday after the first Monday in November of years divisible by
  150. 4:
  151.  
  152.      (sexp (if (= 0 (% year 4))
  153.                (calendar-gregorian-from-absolute
  154.                  (1+ (calendar-dayname-on-or-before
  155.                         1 (+ 6 (calendar-absolute-from-gregorian
  156.                                  (list 11 1 year))))))
  157.            "US Presidential Election"))
  158.  
  159. or
  160.  
  161.      (if (= 0 (% displayed-year 4))
  162.          (fixed 11
  163.                 (extract-calendar-day
  164.                   (calendar-gregorian-from-absolute
  165.                     (1+ (calendar-dayname-on-or-before
  166.                           1 (+ 6 (calendar-absolute-from-gregorian
  167.                                    (list 11 1 displayed-year)))))))
  168.                 "US Presidential Election"))
  169.  
  170.    Some holidays just don't fit into any of these forms because special
  171. calculations are involved in their determination.  In such cases you
  172. must write a Lisp function to do the calculation.  To include eclipses
  173. of the sun, for example, add `(eclipses)' to `other-holidays' and write
  174. an Emacs Lisp function `calendar-holiday-function-eclipses' that
  175. returns a (possibly empty) list of the relevant Gregorian dates among
  176. the range visible in the calendar window, with descriptive strings, like
  177. this:
  178.  
  179.      (((6 27 1991) "Lunar Eclipse") ((7 11 1991) "Solar Eclipse") ... )
  180.  
  181. 
  182. File: elisp,  Node: Date Display Format,  Next: Time Display Format,  Prev: Holiday Customizing,  Up: Calendar
  183.  
  184. Date Display Format
  185. ===================
  186.  
  187.    You can customize the manner of displaying dates in the diary, in
  188. mode lines, and in messages by setting `calendar-date-display-form'.
  189. This variable is a list of expressions that can involve the variables
  190. `month', `day', and `year', all numbers in string form, and `monthname'
  191. and `dayname', both alphabetic strings.  In the American style, the
  192. default value of this list is as follows:
  193.  
  194.      ((if dayname (concat dayname ", ")) monthname " " day ", " year)
  195.  
  196. while in the European style this value is the default:
  197.  
  198.      ((if dayname (concat dayname ", ")) day " " monthname " " year)
  199.  
  200.    The ISO standard date representation is this:
  201.  
  202.      (year "-" month "-" day)
  203.  
  204. This specifies a typical American format:
  205.  
  206.      (month "/" day "/" (substring year -2))
  207.  
  208. 
  209. File: elisp,  Node: Time Display Format,  Next: Daylight Savings,  Prev: Date Display Format,  Up: Calendar
  210.  
  211. Time Display Format
  212. ===================
  213.  
  214.    In the calendar, diary, and related buffers, Emacs displays times of
  215. day in the conventional American style with the hours from 1 through 12,
  216. minutes, and either `am' or `pm'.  If you prefer the "military"
  217. (European) style of writing times--in which the hours go from 00 to
  218. 23--you can alter the variable `calendar-time-display-form'.  This
  219. variable is a list of expressions that can involve the variables
  220. `12-hours', `24-hours', and `minutes', all numbers in string form, and
  221. `am-pm' and `time-zone', both alphabetic strings.  The default
  222. definition of `calendar-time-display-form' is as follows:
  223.  
  224.      (12-hours ":" minutes am-pm
  225.                (if time-zone " (") time-zone (if time-zone ")"))
  226.  
  227.    Setting `calendar-time-display-form' to
  228.  
  229.      (24-hours ":" minutes
  230.                (if time-zone " (") time-zone (if time-zone ")"))
  231.  
  232. gives military-style times like `21:07 (UT)' if time zone names are
  233. defined, and times like `21:07' if they are not.
  234.  
  235. 
  236. File: elisp,  Node: Daylight Savings,  Next: Diary Customizing,  Prev: Time Display Format,  Up: Calendar
  237.  
  238. Daylight Savings Time
  239. =====================
  240.  
  241.    Emacs understands the difference between standard time and daylight
  242. savings time--the times given for sunrise, sunset, solstices,
  243. equinoxes, and the phases of the moon take that into account.  The
  244. default starting and stopping dates for daylight savings time are the
  245. present-day American rules of the first Sunday in April until the last
  246. Sunday in October, but you can specify whatever rules you want by
  247. setting `calendar-daylight-savings-starts' and
  248. `calendar-daylight-savings-ends'.  Their values should be Lisp
  249. expressions that refer to the variable `year', and evaluate to the
  250. Gregorian date on which daylight savings time starts or (respectively)
  251. ends, in the form of a list `(MONTH DAY YEAR)'.
  252.  
  253.    Emacs uses these expressions to determine the starting date of
  254. daylight savings time for the holiday list and for correcting times of
  255. day in the solar and lunar calculations.
  256.  
  257.    The default value of `calendar-daylight-savings-starts' is this,
  258.  
  259.      (calendar-nth-named-day 1 0 4 year)
  260.  
  261. which computes the first 0th day (Sunday) of the fourth month (April) in
  262. the year specified by `year'.  If daylight savings time were changed to
  263. start on October 1, you would set `calendar-daylight-savings-starts' to
  264.  
  265.      (list 10 1 year)
  266.  
  267.    For a more complex example, suppose daylight savings time begins on
  268. the first of Nisan on the Hebrew calendar.  You would set
  269. `calendar-daylight-savings-starts' to
  270.  
  271.      (calendar-gregorian-from-absolute
  272.        (calendar-absolute-from-hebrew
  273.          (list 1 1 (+ year 3760))))
  274.  
  275. because Nisan is the first month in the Hebrew calendar and the Hebrew
  276. year differs from the Gregorian year by 3760 at Nisan.
  277.  
  278.    If there is no daylight savings time at your location, or if you want
  279. all times in standard time, set `calendar-daylight-savings-starts' and
  280. `calendar-daylight-savings-ends' to `nil'.
  281.  
  282. 
  283. File: elisp,  Node: Diary Customizing,  Next: Hebrew/Islamic Entries,  Prev: Daylight Savings,  Up: Calendar
  284.  
  285. Customizing the Diary
  286. =====================
  287.  
  288.    Ordinarily, the mode line of the diary buffer window indicates any
  289. holidays that fall on the date of the diary entries.  The process of
  290. checking for holidays can take several seconds, so including holiday
  291. information delays the display of the diary buffer noticeably.  If you'd
  292. prefer to have a faster display of the diary buffer but without the
  293. holiday information, set the variable `holidays-in-diary-buffer' to
  294. `nil'.
  295.  
  296.    The variable `number-of-diary-entries' controls the number of days
  297. of diary entries to be displayed at one time.  It affects the initial
  298. display when `view-diary-entries-initially' is `t', as well as the
  299. command `M-x diary'.  For example, the default value is 1, which says
  300. to display only the current day's diary entries.  If the value is 2,
  301. both the current day's and the next day's entries are displayed.  The
  302. value can also be a vector of seven elements: if the value is `[0 2 2 2
  303. 2 4 1]' then no diary entries appear on Sunday, the current date's and
  304. the next day's diary entries appear Monday through Thursday, Friday
  305. through Monday's entries appear on Friday, while on Saturday only that
  306. day's entries appear.
  307.  
  308.    The variable `print-diary-entries-hook' is a normal hook run after
  309. preparation of a temporary buffer containing just the diary entries
  310. currently visible in the diary buffer.  (The other, irrelevant diary
  311. entries are really absent from the temporary buffer; in the diary
  312. buffer, they are merely hidden.)  The default value of this hook does
  313. the printing with the command `lpr-buffer'.  If you want to use a
  314. different command to do the printing, just change the value of this
  315. hook.  Other uses might include, for example, rearranging the lines into
  316. order by day and time.
  317.  
  318.    You can customize the form of dates in your diary file, if neither
  319. the standard American nor European styles suits your needs, by setting
  320. the variable `diary-date-forms'.  This variable is a list of forms of
  321. dates recognized in the diary file.  Each form is a list of regular
  322. expressions (*note Regular Expressions::.) and the variables `month',
  323. `day', `year', `monthname', and `dayname'.  The variable `monthname'
  324. matches the name of the month, capitalized or not, or its three-letter
  325. abbreviation, followed by a period or not; it matches `*'.  Similarly,
  326. `dayname' matches the name of the day, capitalized or not, or its
  327. three-letter abbreviation, followed by a period or not.  The variables
  328. `month', `day', and `year' match those numerical values, preceded by
  329. arbitrarily many zeros; they also match `*'.  The default value of
  330. `diary-date-forms' in the American style is
  331.  
  332.      ((month "/" day "[^/0-9]")
  333.       (month "/" day "/" year "[^0-9]")
  334.       (monthname " *" day "[^,0-9]")
  335.       (monthname " *" day ", *" year "[^0-9]")
  336.       (dayname "\\W"))
  337.  
  338. Emacs matches of the diary entries with the date forms is done with the
  339. standard syntax table from Fundamental mode (*note Syntax Tables::.),
  340. but with the `*' changed so that it is a word constituent.
  341.  
  342.    The forms on the list must be *mutually exclusive* and must not
  343. match any portion of the diary entry itself, just the date.  If, to be
  344. mutually exclusive, the pattern must match a portion of the diary entry
  345. itself, the first element of the form *must* be `backup'.  This causes
  346. the date recognizer to back up to the beginning of the current word of
  347. the diary entry.  Even if you use `backup', the form must absolutely
  348. not match more than a portion of the first word of the diary entry.
  349. The default value of `diary-date-forms' in the European style is this
  350. list:
  351.  
  352.      ((day "/" month "[^/0-9]")
  353.       (day "/" month "/" year "[^0-9]")
  354.       (backup day " *" monthname "\\W+\\<[^*0-9]")
  355.       (day " *" monthname " *" year "[^0-9]")
  356.       (dayname "\\W"))
  357.  
  358. Notice the use of `backup' in the middle form because part of the diary
  359. entry must be matched to distinguish this form from the following one.
  360.  
  361. 
  362. File: elisp,  Node: Hebrew/Islamic Entries,  Next: Fancy Diary Display,  Prev: Diary Customizing,  Up: Calendar
  363.  
  364. Hebrew- and Islamic-Date Diary Entries
  365. ======================================
  366.  
  367.    Your diary file can have entries based on Hebrew or Islamic dates, as
  368. well as entries based on our usual Gregorian calendar.  However, because
  369. the processing of such entries is time-consuming and most people don't
  370. need them, you must customize the processing of your diary file to
  371. specify that you want such entries recognized.  If you want Hebrew-date
  372. diary entries, for example, you must include these lines in your
  373. `.emacs' file:
  374.  
  375.      (setq nongregorian-diary-listing-hook 'list-hebrew-diary-entries)
  376.      (setq nongregorian-diary-marking-hook 'mark-hebrew-diary-entries)
  377.  
  378. If you want Islamic-date entries, include these lines in your `.emacs'
  379. file:
  380.  
  381.      (setq nongregorian-diary-listing-hook 'list-islamic-diary-entries)
  382.      (setq nongregorian-diary-marking-hook 'mark-islamic-diary-entries)
  383.  
  384. If you want both Hebrew- and Islamic-date entries, include these lines:
  385.  
  386.      (setq nongregorian-diary-listing-hook
  387.            '(list-hebrew-diary-entries list-islamic-diary-entries))
  388.      (setq nongregorian-diary-marking-hook
  389.            '(mark-hebrew-diary-entries mark-islamic-diary-entries))
  390.  
  391.    Hebrew- and Islamic-date diary entries have the same formats as
  392. Gregorian-date diary entries, except that the date must be preceded with
  393. an `H' for Hebrew dates and an `I' for Islamic dates.  Moreover,
  394. because the Hebrew and Islamic month names are not uniquely specified
  395. by the first three letters, you may not abbreviate them.  For example,
  396. a diary entry for the Hebrew date Heshvan 25 could look like
  397.  
  398.      HHeshvan 25 Happy Hebrew birthday!
  399.  
  400. and would appear in the diary for any date that corresponds to Heshvan
  401. 25 on the Hebrew calendar.  Similarly, an Islamic-date diary entry
  402. might be
  403.  
  404.      IDhu al-Qada 25 Happy Islamic birthday!
  405.  
  406. and would appear in the diary for any date that corresponds to Dhu
  407. al-Qada 25 on the Islamic calendar.
  408.  
  409.    As with Gregorian-date diary entries, Hebrew- and Islamic-date
  410. entries are nonmarking if they are preceded with an ampersand (`&').
  411.  
  412.    There are commands to help you in making Hebrew- and Islamic-date
  413. entries to your diary:
  414.  
  415. `i h d'
  416.      Add a diary entry for the Hebrew date corresponding to the
  417.      selected date (`insert-hebrew-diary-entry').
  418.  
  419. `i h m'
  420.      Add a diary entry for the day of the Hebrew month corresponding to
  421.      the selected date (`insert-monthly-hebrew-diary-entry').
  422.  
  423. `i h y'
  424.      Add a diary entry for the day of the Hebrew year corresponding to
  425.      the selected date (`insert-yearly-hebrew-diary-entry').
  426.  
  427. `i i d'
  428.      Add a diary entry for the Islamic date corresponding to the
  429.      selected date (`insert-islamic-diary-entry').
  430.  
  431. `i i m'
  432.      Add a diary entry for the day of the Islamic month corresponding
  433.      to the selected date (`insert-monthly-islamic-diary-entry').
  434.  
  435. `i i y'
  436.      Add a diary entry for the day of the Islamic year corresponding to
  437.      the selected date (`insert-yearly-islamic-diary-entry').
  438.  
  439.    These commands work exactly like the corresponding commands for
  440. ordinary diary entries: Move point to a date in the calendar window and
  441. the above commands insert the Hebrew or Islamic date (corresponding to
  442. the date indicated by point) at the end of your diary file and you can
  443. then type the diary entry.  If you want the diary entry to be
  444. nonmarking, give a numeric argument to the command.
  445.  
  446. 
  447. File: elisp,  Node: Fancy Diary Display,  Next: Included Diary Files,  Prev: Hebrew/Islamic Entries,  Up: Calendar
  448.  
  449. Fancy Diary Display
  450. ===================
  451.  
  452.    Diary display works by preparing the diary buffer and then running
  453. the hook `diary-display-hook'.  The default value of this hook hides
  454. the irrelevant diary entries and then displays the buffer
  455. (`simple-diary-display').  However, if you specify the hook as follows,
  456.  
  457.      (add-hook 'diary-display-hook 'fancy-diary-display)
  458.  
  459. then fancy mode displays diary entries and holidays by copying them into
  460. a special buffer that exists only for display.  Copying provides an
  461. opportunity to change the displayed text to make it prettier--for
  462. example, to sort the entries by the dates they apply to.
  463.  
  464.    As with simple diary display, you can print a hard copy of the buffer
  465. with `print-diary-entries'.  To print a hard copy of a day-by-day diary
  466. for a week by positioning point on Sunday of that week, type `7 d' and
  467. then do `M-x print-diary-entries'.  As usual, the inclusion of the
  468. holidays slows down the display slightly; you can speed things up by
  469. setting the variable `holidays-in-diary-buffer' to `nil'.
  470.  
  471.    Ordinarily, the fancy diary buffer does not show days for which
  472. there are no diary entries, even if that day is a holiday.  If you want
  473. such days to be shown in the fancy diary buffer, set the variable
  474. `diary-list-include-blanks' to `t'.
  475.  
  476.    If you use the fancy diary display, you can use the normal hook
  477. `list-diary-entries-hook' to sort each day's diary entries by their
  478. time of day.  Add this line to your `.emacs' file:
  479.  
  480.      (add-hook 'list-diary-entries-hook 'sort-diary-entries)
  481.  
  482. For each day, this sorts diary entries that begin with a recognizable
  483. time of day according to their times.  Diary entries without times come
  484. first within each day.
  485.  
  486. 
  487. File: elisp,  Node: Included Diary Files,  Next: Sexp Diary Entries,  Prev: Fancy Diary Display,  Up: Calendar
  488.  
  489. Included Diary Files
  490. ====================
  491.  
  492.    If you use the fancy diary display, you can have diary entries from
  493. other files included with your own by an "include" mechanism.  This
  494. facility makes possible the sharing of common diary files among groups
  495. of users.  Lines in the diary file of this form:
  496.  
  497.      #include "FILENAME"
  498.  
  499. includes the diary entries from the file FILENAME in the fancy diary
  500. buffer (because the ordinary diary buffer is just the buffer associated
  501. with your diary file, you cannot use the include mechanism unless you
  502. use the fancy diary buffer).  The include mechanism is recursive, by
  503. the way, so that included files can include other files, and so on; you
  504. must be careful not to have a cycle of inclusions, of course.  To
  505. enable the include facility, add lines as follows to your `.emacs' file:
  506.  
  507.      (add-hook 'list-diary-entries-hook 'include-other-diary-files)
  508.      (add-hook 'mark-diary-entries-hook 'mark-included-diary-files)
  509.  
  510. 
  511. File: elisp,  Node: Sexp Diary Entries,  Next: Appt Customizing,  Prev: Included Diary Files,  Up: Calendar
  512.  
  513. Sexp Entries and the Fancy Diary Display
  514. ========================================
  515.  
  516.    Sexp diary entries allow you to do more than just have complicated
  517. conditions under which a diary entry applies.  If you use the fancy
  518. diary display, sexp entries can generate the text of the entry depending
  519. on the date itself.  For example, an anniversary diary entry can insert
  520. the number of years since the anniversary date into the text of the
  521. diary entry.  Thus the `%d' in this dairy entry:
  522.  
  523.      %%(diary-anniversary 10 31 1948) Arthur's birthday (%d years old)
  524.  
  525. gets replaced by the age, so on October 31, 1990 the entry appears in
  526. the fancy diary buffer like this:
  527.  
  528.      Arthur's birthday (42 years old)
  529.  
  530. If the diary file instead contains this entry:
  531.  
  532.      %%(diary-anniversary 10 31 1948) Arthur's %d%s birthday
  533.  
  534. the entry in the fancy diary buffer for October 31, 1990 appears like
  535. this:
  536.  
  537.      Arthur's 42nd birthday
  538.  
  539.    Similarly, cyclic diary entries can interpolate the number of
  540. repetitions that have occurred:
  541.  
  542.      %%(diary-cyclic 50 1 1 1990) Renew medication (%d%s time)
  543.  
  544. looks like this:
  545.  
  546.      Renew medication (5th time)
  547.  
  548. in the fancy diary display on September 8, 1990.
  549.  
  550.    The generality of sexp diary entries lets you specify any diary entry
  551. that you can describe algorithmically.  Suppose you get paid on the 21st
  552. of the month if it is a weekday, and to the Friday before if the 21st is
  553. on a weekend.  The diary entry
  554.  
  555.      &%%(let ((dayname (calendar-day-of-week date))
  556.               (day (car (cdr date))))
  557.            (or (and (= day 21) (memq dayname '(1 2 3 4 5)))
  558.                (and (memq day '(19 20)) (= dayname 5)))
  559.               ) Pay check deposited
  560.  
  561. applies to just those dates.  This example illustrates how the sexp can
  562. depend on the variable `date'; this variable is a list (MONTH DAY YEAR)
  563. that gives the Gregorian date for which the diary entries are being
  564. found.  If the value of the expression is `t', the entry applies to
  565. that date.  If the expression evaluates to `nil', the entry does *not*
  566. apply to that date.
  567.  
  568.    The following sexp diary entries take advantage of the ability (in
  569. the fancy diary display) to concoct diary entries based on the date:
  570.  
  571. `%%(diary-sunrise-sunset)'
  572.      Make a diary entry for the local times of today's sunrise and
  573.      sunset.
  574.  
  575. `%%(diary-phases-of-moon)'
  576.      Make a diary entry for the phases (quarters) of the moon.
  577.  
  578. `%%(diary-day-of-year)'
  579.      Make a diary entry with today's day number in the current year and
  580.      the number of days remaining in the current year.
  581.  
  582. `%%(diary-iso-date)'
  583.      Make a diary entry with today's equivalent ISO commercial date.
  584.  
  585. `%%(diary-julian-date)'
  586.      Make a diary entry with today's equivalent date on the Julian
  587.      calendar.
  588.  
  589. `%%(diary-astro-day-number)'
  590.      Make a diary entry with today's equivalent astronomical (Julian)
  591.      day number.
  592.  
  593. `%%(diary-hebrew-date)'
  594.      Make a diary entry with today's equivalent date on the Hebrew
  595.      calendar.
  596.  
  597. `%%(diary-islamic-date)'
  598.      Make a diary entry with today's equivalent date on the Islamic
  599.      calendar.
  600.  
  601. `%%(diary-french-date)'
  602.      Make a diary entry with today's equivalent date on the French
  603.      Revolutionary calendar.
  604.  
  605. `%%(diary-mayan-date)'
  606.      Make a diary entry with today's equivalent date on the Mayan
  607.      calendar.
  608.  
  609. Thus including the diary entry
  610.  
  611.      &%%(diary-hebrew-date)
  612.  
  613. causes every day's diary display to contain the equivalent date on the
  614. Hebrew calendar, if you are using the fancy diary display.  (With simple
  615. diary display, the line `&%%(diary-hebrew-date)' appears in the diary
  616. for any date, but does nothing particularly useful.)
  617.  
  618.    There are a number of other available sexp diary entries that are
  619. important to those who follow the Hebrew calendar:
  620.  
  621. `%%(diary-rosh-hodesh)'
  622.      Make a diary entry that tells the occurrence and ritual
  623.      announcement of each new Hebrew month.
  624.  
  625. `%%(diary-parasha)'
  626.      Make a Saturday diary entry that tells the weekly synagogue
  627.      scripture reading.
  628.  
  629. `%%(diary-sabbath-candles)'
  630.      Make a Friday diary entry that tells the *local time* of Sabbath
  631.      candle lighting.
  632.  
  633. `%%(diary-omer)'
  634.      Make a diary entry that gives the omer count, when appropriate.
  635.  
  636. `%%(diary-yahrzeit MONTH DAY YEAR) NAME'
  637.      Make a diary entry marking the anniversary of a date of death.
  638.      The date is the *Gregorian* (civil) date of death.  The diary
  639.      entry appears on the proper Hebrew calendar anniversary and on the
  640.      day before.  (In the European style, the order of the parameters
  641.      is changed to DAY, MONTH, YEAR.)
  642.  
  643. 
  644. File: elisp,  Node: Appt Customizing,  Prev: Sexp Diary Entries,  Up: Calendar
  645.  
  646. Customizing Appointment Reminders
  647. =================================
  648.  
  649.    You can specify exactly how Emacs reminds you of an appointment and
  650. how far in advance it begins doing so.  Here are the variables that you
  651. can set:
  652.  
  653. `appt-message-warning-time'
  654.      The time in minutes before an appointment that the reminder
  655.      begins.  The default is 10 minutes.
  656.  
  657. `appt-audible'
  658.      If this is `t' (the default), Emacs rings the terminal bell for
  659.      appointment reminders.
  660.  
  661. `appt-visible'
  662.      If this is `t' (the default), Emacs displays the appointment
  663.      message in echo area.
  664.  
  665. `appt-display-mode-line'
  666.      If this is `t' (the default), Emacs displays the number of minutes
  667.      to the appointment on the mode line.
  668.  
  669. `appt-msg-window'
  670.      If this is `t' (the default), Emacs displays the appointment
  671.      message in another window.
  672.  
  673. `appt-display-duration'
  674.      The number of seconds an appointment message is displayed.  The
  675.      default is 5 seconds.
  676.  
  677. 
  678. File: elisp,  Node: Tips,  Next: GNU Emacs Internals,  Prev: Calendar,  Up: Top
  679.  
  680. Tips and Standards
  681. ******************
  682.  
  683.    This chapter describes no additional features of Emacs Lisp.
  684. Instead it gives advice on making effective use of the features
  685. described in the previous chapters.
  686.  
  687. * Menu:
  688.  
  689. * Style Tips::                Writing clean and robust programs.
  690. * Compilation Tips::          Making compiled code run fast.
  691. * Documentation Tips::        Writing readable documentation strings.
  692. * Comment Tips::          Conventions for writing comments.
  693. * Library Headers::           Standard headers for library packages.
  694.  
  695. 
  696. File: elisp,  Node: Style Tips,  Next: Compilation Tips,  Up: Tips
  697.  
  698. Writing Clean Lisp Programs
  699. ===========================
  700.  
  701.    Here are some tips for avoiding common errors in writing Lisp code
  702. intended for widespread use:
  703.  
  704.    * Since all global variables share the same name space, and all
  705.      functions share another name space, you should choose a short word
  706.      to distinguish your program from other Lisp programs.  Then take
  707.      care to begin the names of all global variables, constants, and
  708.      functions with the chosen prefix.  This helps avoid name conflicts.
  709.  
  710.      This recommendation applies even to names for traditional Lisp
  711.      primitives that are not primitives in Emacs Lisp--even to `cadr'.
  712.      Believe it or not, there is more than one plausible way to define
  713.      `cadr'.  Play it safe; append your name prefix to produce a name
  714.      like `foo-cadr' or `mylib-cadr' instead.
  715.  
  716.      If one prefix is insufficient, your package may use two or three
  717.      alternative common prefixes, so long as they make sense.
  718.  
  719.      Separate the prefix from the rest of the symbol name with a hyphen,
  720.      `-'.  This will be consistent with Emacs itself and with most Emacs
  721.      Lisp programs.
  722.  
  723.    * It is often useful to put a call to `provide' in each separate
  724.      library program, at least if there is more than one entry point to
  725.      the program.
  726.  
  727.    * If one file FOO uses a macro defined in another file BAR, FOO
  728.      should contain `(require 'BAR)' before the first use of the macro.
  729.      (And BAR should contain `(provide 'BAR)', to make the `require'
  730.      work.)  This will cause BAR to be loaded when you byte-compile
  731.      FOO.  Otherwise, you risk compiling FOO without the necessary
  732.      macro loaded, and that would produce compiled code that won't work
  733.      right.  *Note Compiling Macros::.
  734.  
  735.    * If you define a major mode, make sure to run a hook variable using
  736.      `run-hooks', just as the existing major modes do.  *Note Hooks::.
  737.  
  738.    * Please do not define `C-c LETTER' as a key in your major modes.
  739.      These sequences are reserved for users; they are the *only*
  740.      sequences reserved for users, so we cannot do without them.
  741.  
  742.      Instead, define sequences consisting of `C-c' followed by a
  743.      non-letter.  These sequences are reserved for major modes.
  744.  
  745.      Changing all the major modes in Emacs 18 so they would follow this
  746.      convention was a lot of work.  Abandoning this convention would
  747.      waste that work and inconvenience the users.
  748.  
  749.    * It is a bad idea to define aliases for the Emacs primitives.  Use
  750.      the standard names instead.
  751.  
  752.    * Redefining an Emacs primitive is an even worse idea.  It may do
  753.      the right thing for a particular program, but there is no telling
  754.      what other programs might break as a result.
  755.  
  756.    * If a file does replace any of the functions or library programs of
  757.      standard Emacs, prominent comments at the beginning of the file
  758.      should say which functions are replaced, and how the behavior of
  759.      the replacements differs from that of the originals.
  760.  
  761.    * If a file requires certain standard library programs to be loaded
  762.      beforehand, then the comments at the beginning of the file should
  763.      say so.
  764.  
  765.    * Please keep the names of your Emacs Lisp source files to 13
  766.      characters or less.  This way, if the files are compiled, the
  767.      compiled files' names will be 14 characters or less, which is
  768.      short enough to fit on all kinds of Unix systems.
  769.  
  770.    * Don't use `next-line' or `previous-line' in programs; nearly
  771.      always, `forward-line' is more convenient as well as more
  772.      predictable and robust.  *Note Text Lines::.
  773.  
  774.    * Don't use functions that set the mark in your Lisp code (unless
  775.      you are writing a command to set the mark).  The mark is a
  776.      user-level feature, so it is incorrect to change the mark except
  777.      to supply a value for the user's benefit.  *Note The Mark::.
  778.  
  779.      In particular, don't use these functions:
  780.  
  781.         * `beginning-of-buffer', `end-of-buffer'
  782.  
  783.         * `replace-string', `replace-regexp'
  784.  
  785.      If you just want to move point, or replace a certain string,
  786.      without any of the other features intended for interactive users,
  787.      you can replace these functions with one or two lines of simple
  788.      Lisp code.
  789.  
  790.    * The recommended way to print a message in the echo area is with
  791.      the `message' function, not `princ'.  *Note The Echo Area::.
  792.  
  793.    * When you encounter an error condition, call the function `error'
  794.      (or `signal').  The function `error' does not return.  *Note
  795.      Signaling Errors::.
  796.  
  797.      Do not use `message', `throw', `sleep-for', or `beep' to report
  798.      errors.
  799.  
  800.    * Avoid using recursive edits.  Instead, do what the Rmail `w'
  801.      command does: use a new local keymap that contains one command
  802.      defined to switch back to the old local keymap.  Or do what the
  803.      `edit-options' command does: switch to another buffer and let the
  804.      user switch back at will.  *Note Recursive Editing::.
  805.  
  806.    * In some other systems there is a convention of choosing variable
  807.      names that begin and end with `*'.  We don't use that convention
  808.      in Emacs Lisp, so please don't use it in your library.  (In fact,
  809.      in Emacs names of this form are conventionally used for
  810.      program-generated buffers.) The users will find Emacs more
  811.      coherent if all libraries use the same conventions.
  812.  
  813.    * Indent each function with `C-M-q' (`indent-sexp') using the
  814.      default indentation parameters.
  815.  
  816.    * Don't make a habit of putting close-parentheses on lines by
  817.      themselves; Lisp programmers find this disconcerting.  Once in a
  818.      while, when there is a sequence of many consecutive
  819.      close-parentheses, it may make sense to split them in one or two
  820.      significant places.
  821.  
  822.    * Please put a copyright notice on the file if you give copies to
  823.      anyone.  Use the same lines that appear at the top of the Lisp
  824.      files in Emacs itself.  If you have not signed papers to assign
  825.      the copyright to the Foundation, then place your name in the
  826.      copyright notice in place of the Foundation's name.
  827.  
  828. 
  829. File: elisp,  Node: Compilation Tips,  Next: Documentation Tips,  Prev: Style Tips,  Up: Tips
  830.  
  831. Tips for Making Compiled Code Fast
  832. ==================================
  833.  
  834.    Here are ways of improving the execution speed of byte-compiled lisp
  835. programs.
  836.  
  837.    * Use the `profile' library to profile your program.  See the file
  838.      `profile.el' for instructions.
  839.  
  840.    * Use iteration rather than recursion whenever possible.  Function
  841.      calls are slow in Emacs Lisp even when a compiled function is
  842.      calling another compiled function.
  843.  
  844.    * Using the primitive list-searching functions `memq', `assq' or
  845.      `assoc' is even faster than explicit iteration.  It may be worth
  846.      rearranging a data structure so that one of these primitive search
  847.      functions can be used.
  848.  
  849.    * Certain built-in functions are handled specially by the byte
  850.      compiler avoiding the need for an ordinary function call.  It is a
  851.      good idea to use these functions rather than alternatives.  To see
  852.      whether a function is handled specially by the compiler, examine
  853.      its `byte-compile' property.  If the property is non-`nil', then
  854.      the function is handled specially.
  855.  
  856.      For example, the following input will show you that `aref' is
  857.      compiled specially (*note Array Functions::.) while `elt' is not
  858.      (*note Sequence Functions::.):
  859.  
  860.           (get 'aref 'byte-compile)
  861.                => byte-compile-two-args
  862.  
  863.           (get 'elt 'byte-compile)
  864.                => nil
  865.  
  866.    * Make small functions inline, so that calls to them in compiled
  867.      code run faster.  *Note Inline Functions::.
  868.  
  869. 
  870. File: elisp,  Node: Documentation Tips,  Next: Comment Tips,  Prev: Compilation Tips,  Up: Tips
  871.  
  872. Tips for Documentation Strings
  873. ==============================
  874.  
  875.    Here are some tips for the writing of documentation strings.
  876.  
  877.    * Every command, function or variable intended for users to know
  878.      about should have a documentation string.
  879.  
  880.    * An internal subroutine of a Lisp program need not have a
  881.      documentation string, and you can save space by using a comment
  882.      instead.
  883.  
  884.    * The first line of the documentation string should consist of one
  885.      or two complete sentences which stand on their own as a summary.
  886.      In particular, start the line with a capital letter and end with a
  887.      period.
  888.  
  889.      The documentation string can have additional lines which expand on
  890.      the details of how to use the function or variable.  The
  891.      additional lines should be made up of complete sentences also, but
  892.      they may be filled if that looks good.
  893.  
  894.    * Do not start or end a documentation string with whitespace.
  895.  
  896.    * Format the documentation string so that it fits in an Emacs window
  897.      on an 80 column screen.  It is a good idea for most lines to be no
  898.      wider than 60 characters.  The first line can be wider if
  899.      necessary to fit the information that ought to be there.
  900.  
  901.      However, rather than simply filling the entire documentation
  902.      string, you can make it much more readable by choosing line breaks
  903.      with care.  Use blank lines between topics if the documentation
  904.      string is long.
  905.  
  906.    * *Do not* indent subsequent lines of a documentation string so that
  907.      the text is lined up in the source code with the text of the first
  908.      line.  This looks nice in the source code, but looks bizarre when
  909.      users view the documentation.  Remember that the indentation
  910.      before the starting double-quote is not part of the string!
  911.  
  912.    * A variable's documentation string should start with `*' if the
  913.      variable is one that users would want to set interactively often.
  914.      If the value is a long list, or a function, or if the variable
  915.      would only be set in init files, then don't start the
  916.      documentation string with `*'.  *Note Defining Variables::.
  917.  
  918.    * The documentation string for a variable that is a yes-or-no flag
  919.      should start with words such as "Non-nil means...", to make it
  920.      clear both that the variable only has two meaningfully distinct
  921.      values and which value means "yes".
  922.  
  923.    * When a function's documentation string mentions the value of an
  924.      argument of the function, use the argument name in capital letters
  925.      as if it were a name for that value.  Thus, the documentation
  926.      string of the function `/' refers to its second argument as
  927.      `DIVISOR'.
  928.  
  929.      Also use all caps for meta-syntactic variables, such as when you
  930.      show the decomposition of a list or vector into subunits, some of
  931.      which may be variable.
  932.  
  933.    * When a documentation string refers to a Lisp symbol, write it as it
  934.      would be printed (which usually means in lower case), with
  935.      single-quotes around it.  For example: ``lambda''.  There are two
  936.      exceptions: write `t' and `nil' without single-quotes.
  937.  
  938.    * Don't write key sequences directly in documentation strings.
  939.      Instead, use the `\\[...]' construct to stand for them.  For
  940.      example, instead of writing `C-f', write `\\[forward-char]'.  When
  941.      the documentation string is printed, Emacs will substitute
  942.      whatever key is currently bound to `forward-char'.  This will
  943.      usually be `C-f', but if the user has moved key bindings, it will
  944.      be the correct key for that user.  *Note Keys in Documentation::.
  945.  
  946.    * In documentation strings for a major mode, you will want to refer
  947.      to the key bindings of that mode's local map, rather than global
  948.      ones.  Therefore, use the construct `\\<...>' once in the
  949.      documentation string to specify which key map to use.  Do this
  950.      before the first use of `\\[...]'.  The text inside the `\\<...>'
  951.      should be the name of the variable containing the local keymap for
  952.      the major mode.
  953.  
  954.      It is not practical to use `\\[...]' very many times, because
  955.      display of the documentation string will become slow.  So use this
  956.      to describe the most important commands in your major mode, and
  957.      then use `\\{...}' to display the rest of the mode's keymap.
  958.  
  959.    * Don't use the term "Elisp", since that is or was a trademark.  Use
  960.      the term "Emacs Lisp".
  961.  
  962. 
  963. File: elisp,  Node: Comment Tips,  Next: Library Headers,  Prev: Documentation Tips,  Up: Tips
  964.  
  965. Tips on Writing Comments
  966. ========================
  967.  
  968.    We recommend these conventions for where to put comments and how to
  969. indent them:
  970.  
  971. `;'
  972.      Comments that start with a single semicolon, `;', should all be
  973.      aligned to the same column on the right of the source code.  Such
  974.      comments usually explain how the code on the same line does its
  975.      job.  In Lisp mode and related modes, the `M-;'
  976.      (`indent-for-comment') command automatically inserts such a `;' in
  977.      the right place, or aligns such a comment if it is already
  978.      inserted.
  979.  
  980.      (The following examples are taken from the Emacs sources.)
  981.  
  982.           (setq base-version-list                 ; there was a base
  983.                 (assoc (substring fn 0 start-vn)  ; version to which
  984.                        file-version-assoc-list))  ; this looks like
  985.                                                   ; a subversion
  986.  
  987. `;;'
  988.      Comments that start with two semicolons, `;;', should be aligned to
  989.      the same level of indentation as the code.  Such comments are used
  990.      to describe the purpose of the following lines or the state of the
  991.      program at that point.  For example:
  992.  
  993.           (prog1 (setq auto-fill-function
  994.                        ...
  995.                        ...
  996.             ;; update mode-line
  997.             (force-mode-line-update)))
  998.  
  999.      These comments are also written before a function definition to
  1000.      explain what the function does and how to call it properly.
  1001.  
  1002. `;;;'
  1003.      Comments that start with three semicolons, `;;;', should start at
  1004.      the left margin.  Such comments are not used within function
  1005.      definitions, but are used to make more general comments.  For
  1006.      example:
  1007.  
  1008.           ;;; This Lisp code is run in Emacs
  1009.           ;;; when it is to operate as a server
  1010.           ;;; for other processes.
  1011.  
  1012. `;;;;'
  1013.      Comments that start with four semicolons, `;;;;', should be aligned
  1014.      to the left margin and are used for headings of major sections of a
  1015.      program.  For example:
  1016.  
  1017.           ;;;; The kill ring
  1018.  
  1019. The indentation commands of the Lisp modes in Emacs, such as `M-;'
  1020. (`indent-for-comment') and TAB (`lisp-indent-line') automatically
  1021. indent comments according to these conventions, depending on the the
  1022. number of semicolons.  *Note Manipulating Comments: (emacs)Comments.
  1023.  
  1024.    If you wish to "comment out" a number of lines of code, use triple
  1025. semicolons at the beginnings of the lines.
  1026.  
  1027.    Any character may be included in a comment, but it is advisable to
  1028. precede a character with syntactic significance in Lisp (such as `\' or
  1029. unpaired `(' or `)') with a `\', to prevent it from confusing the Emacs
  1030. commands for editing Lisp.
  1031.  
  1032. 
  1033. File: elisp,  Node: Library Headers,  Prev: Comment Tips,  Up: Tips
  1034.  
  1035. Conventional Headers for Emacs Libraries
  1036. ========================================
  1037.  
  1038.    Emacs 19 has conventions for using special comments in Lisp libraries
  1039. to divide them into sections and give information such as who wrote
  1040. them.  This section explains these conventions.  First, an example:
  1041.  
  1042.      ;;; lisp-mnt.el --- minor mode for Emacs Lisp maintainers
  1043.      
  1044.      ;; Copyright (C) 1992 Free Software Foundation, Inc.
  1045.      
  1046.      ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
  1047.      ;; Maintainer: Eric S. Raymond <esr@snark.thyrsus.com>
  1048.      ;; Created: 14 Jul 1992
  1049.      ;; Version: 1.2
  1050.      ;; Keywords: docs
  1051.      
  1052.      ;; This file is part of GNU Emacs.
  1053.      COPYING CONDITIONS...
  1054.  
  1055.    The very first line should have this format:
  1056.  
  1057.      ;;; FILENAME --- DESCRIPTION
  1058.  
  1059. The description should be complete in one line.
  1060.  
  1061.    After the copyright notice come several "header comment" lines, each
  1062. beginning with `;;; HEADER-NAME:'.  Here is a table of the conventional
  1063. possibilities for HEADER-NAME:
  1064.  
  1065. `Author'
  1066.      This line states the name and net address of at least the principal
  1067.      author of the library.
  1068.  
  1069.      If there are multiple authors, you can list them on continuation
  1070.      lines led by `;;<TAB>', like this:
  1071.  
  1072.           ;; Author: Ashwin Ram <Ram-Ashwin@cs.yale.edu>
  1073.           ;;    Dave Sill <de5@ornl.gov>
  1074.           ;;    Dave Brennan <brennan@hal.com>
  1075.           ;;    Eric Raymond <esr@snark.thyrsus.com>
  1076.  
  1077. `Maintainer'
  1078.      This line should contain a single name/address as in the Author
  1079.      line, or an address only, or the string "FSF".  If there is no
  1080.      maintainer line, the person(s) in the Author field are presumed to
  1081.      be the maintainers.  The example above is mildly bogus because the
  1082.      maintainer line is redundant.
  1083.  
  1084.      The idea behind the `Author' and `Maintainer' lines is to make
  1085.      possible a Lisp function to "send mail to the maintainer" without
  1086.      having to mine the name out by hand.
  1087.  
  1088.      Be sure to surround the network address with `<...>' if you
  1089.      include the person's full name as well as the network address.
  1090.  
  1091. `Created'
  1092.      This optional line gives the original creation date of the file.
  1093.      For historical interest only.
  1094.  
  1095. `Version'
  1096.      If you wish to record version numbers for the individual Lisp
  1097.      program, put them in this line.
  1098.  
  1099. `Adapted-By'
  1100.      In this header line, place the name of the person who adapted the
  1101.      library for installation (to make it fit the style conventions, for
  1102.      example).
  1103.  
  1104. `Keywords'
  1105.      This line lists keywords for the `finder-by-keyword' help command.
  1106.      This field is important; it's how people will find your package
  1107.      when they're looking for things by topic area.
  1108.  
  1109.    Just about every Lisp library ought to have the `Author' and
  1110. `Keywords' header comment lines.  Use the others if they are
  1111. appropriate.  You can also put in header lines with other header
  1112. names--they have no standard meanings, so they can't do any harm.
  1113.  
  1114.    We use additional stylized comments to subdivide the contents of the
  1115. library file.  Here is a table of them:
  1116.  
  1117. `;;; Commentary:'
  1118.      This begins introductory comments that explain how the library
  1119.      works.  It should come right after the copying permissions.
  1120.  
  1121. `;;; Change log:'
  1122.      This begins change log information stored in the library file (if
  1123.      you store the change history there).  For most of the Lisp files
  1124.      distributed with Emacs, the change history is kept in the file
  1125.      `ChangeLog' and not in the source file at all; these files do not
  1126.      have a `;;; Change log:' line.
  1127.  
  1128. `;;; Code:'
  1129.      This begins the actual code of the program.
  1130.  
  1131. `;;; FILENAME ends here'
  1132.      This is the "footer line"; it appears at the very end of the file.
  1133.      Its purpose is to enable people to detect truncated versions of
  1134.      the file from the lack of a footer line.
  1135.  
  1136. 
  1137. File: elisp,  Node: GNU Emacs Internals,  Next: Standard Errors,  Prev: Tips,  Up: Top
  1138.  
  1139. GNU Emacs Internals
  1140. *******************
  1141.  
  1142.    This chapter describes how the runnable Emacs executable is dumped
  1143. with the preloaded Lisp libraries in it, how storage is allocated, and
  1144. some internal aspects of GNU Emacs that may be of interest to C
  1145. programmers.
  1146.  
  1147. * Menu:
  1148.  
  1149. * Building Emacs::      How to preload Lisp libraries into Emacs.
  1150. * Pure Storage::        A kludge to make preloaded Lisp functions sharable.
  1151. * Garbage Collection::  Reclaiming space for Lisp objects no longer used.
  1152. * Object Internals::    Data formats of buffers, windows, processes.
  1153. * Writing Emacs Primitives::   Writing C code for Emacs.
  1154.  
  1155. 
  1156. File: elisp,  Node: Building Emacs,  Next: Pure Storage,  Prev: GNU Emacs Internals,  Up: GNU Emacs Internals
  1157.  
  1158. Building Emacs
  1159. ==============
  1160.  
  1161.    The first step in building Emacs is to compile the C sources.  This
  1162. produces a program called `temacs', also called a "bare impure Emacs".
  1163. It contains the Emacs Lisp interpreter and I/O routines, but not the
  1164. editing commands.
  1165.  
  1166.    Then, to create a working Emacs editor, issue the `temacs -l loadup'
  1167. command.  This directs `temacs' to evaluate the Lisp files specified in
  1168. the file `loadup.el'.  These files set up the normal Emacs editing
  1169. environment, resulting in an Emacs which is still impure but no longer
  1170. bare.
  1171.  
  1172.    It takes a long time to load the standard Lisp files.  Luckily, you
  1173. don't have to do this each time you run Emacs; `temacs' can dump out an
  1174. executable program called `emacs' which has these files preloaded.
  1175. `emacs' starts more quickly because it does not need to load the files.
  1176. This is the program that is normally installed.
  1177.  
  1178.    To create `emacs', use the command `temacs -batch -l loadup dump'.
  1179. The purpose of `-batch' here is to prevent `temacs' from trying to
  1180. initialize any of its data on the terminal; this ensures that the
  1181. tables of terminal information are empty in the dumped Emacs.
  1182.  
  1183.    When the `emacs' executable is started, it automatically loads the
  1184. user's `.emacs' file, or the default initialization file `default.el'
  1185. if the user has none.  (*Note Starting Up::.)  With the `.emacs' file,
  1186. you can produce a version of Emacs that suits you and is not the same
  1187. as the version other people use.  With `default.el', you can customize
  1188. Emacs for all the users at your site who don't choose to customize it
  1189. for themselves.  (For further reflection: why is this different from
  1190. the case of the barber who shaves every man who doesn't shave himself?)
  1191.  
  1192.    On some systems, dumping does not work.  Then, you must start Emacs
  1193. with the `temacs -l loadup' command each time you use it.  This takes a
  1194. long time, but since you need to start Emacs once a day at most--and
  1195. once a week or less frequently if you never log out--the extra time is
  1196. not too severe a problem.
  1197.  
  1198.    Before `emacs' is dumped, the documentation strings for primitive
  1199. and preloaded functions (and variables) need to be found in the file
  1200. where they are stored.  This is done by calling `Snarf-documentation'
  1201. (*note Accessing Documentation::.).  These strings were moved out of
  1202. `emacs' to make it smaller.  *Note Documentation Basics::.
  1203.  
  1204.  - Function: dump-emacs TO-FILE FROM-FILE
  1205.      This function dumps the current state of Emacs into an executable
  1206.      file TO-FILE.  It takes symbols from FROM-FILE (this is normally
  1207.      the executable file `temacs').
  1208.  
  1209.      If you use this function in an Emacs that was already dumped, you
  1210.      must set `command-line-processed' to `nil' first for good results.
  1211.      *Note Command Line Arguments::.
  1212.  
  1213.  - Command: emacs-version
  1214.      This function returns a string describing the version of Emacs
  1215.      that is running.  It is useful to include this string in bug
  1216.      reports.
  1217.  
  1218.           (emacs-version)
  1219.             => "GNU Emacs 18.36.1 of Fri Feb 27 1987 on slug
  1220.                (berkeley-unix)"
  1221.  
  1222.      Called interactively, the function prints the same information in
  1223.      the echo area.
  1224.  
  1225.  - Variable: emacs-build-time
  1226.      The value of this variable is the time at which Emacs was built at
  1227.      the local site.
  1228.  
  1229.           emacs-build-time
  1230.                => "Fri Feb 27 14:55:57 1987"
  1231.  
  1232.  - Variable: emacs-version
  1233.      The value of this variable is the version of Emacs being run.  It
  1234.      is a string, e.g. `"18.36.1"'.
  1235.  
  1236.